package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.WarehouseVo;
import cn.ywsj.ywsjmidtier.service.WechatWarehouseRestFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping({"/wechat/member/warehousemgr"})
public class WechatWarehouseRestController {

    @Autowired
    private WechatWarehouseRestFeign restFeign;

    @PostMapping("/addwarehouse")
    public String addWarehouse(WarehouseVo warehouseVo, BindingResult result) {
        return restFeign.addWarehouse(JsonObjectUtil.ObjectToJson(warehouseVo),result);
    }

    @GetMapping("/getwarehouselist")
    public String ajaxWarehouseList(Integer start,Integer pageSize) {
        return  restFeign.ajaxWarehouseList(start,pageSize);
    }

    @GetMapping("/getwarehousedetail")
    public String getWarehouseDetail(Long warehouseId) {
        return restFeign.getWarehouseDetail(warehouseId);
    }

    @GetMapping("/modifywarehouse")
    public String modifyWarehouse(WarehouseVo warehouseVo, BindingResult result) {
        return restFeign.modifyWarehouse(JsonObjectUtil.ObjectToJson(warehouseVo),result);
    }

    @RequestMapping({"/ajaxdelwarehouse"})
    public String ajaxDelWarehouse(WarehouseVo warehouseVo) {
        return restFeign.ajaxDelWarehouse(JsonObjectUtil.ObjectToJson(warehouseVo));
    }
}
